<?php include "top.php"; ?>
      <div id="top-3">
        <div id="m-text-1">
          <ul>
            <li>系統管理功能</li>
           
            <li><a href="admin_manage.php">管理管理員</a></li>
            <li><a href="banner.php">管理首页图片</a></li>
			
           
          </ul>
        </div>
        <div id="m-text-2">
<table width="796" border="0" cellpadding="2" cellspacing="1" class="table_southidc">
        <tr> 
          <td width="851"  height="20" class="back_southidc" > <div align="center"><strong>增加管理員</strong></div></td>
        </tr>
        <tr class="tr_southidc"> 
		
		
		
		
		
		
		<?php 
//修改数据
$id=make_safe($_GET["id"]);
$box1=make_safe($_GET["box1"]);
$box2=make_safe($_GET["box2"]);
$box3=make_safe($_GET["box3"]);
$box4=make_safe($_GET["box4"]);
$box5=make_safe($_GET["box5"]);
$box6=make_safe($_GET["box6"]);
$box7=make_safe($_GET["box7"]);
$box8=make_safe($_GET["box8"]);
$box9=make_safe($_GET["box9"]);


include("check.php");


if($id!="" and $box1!=""){
$query=mysql_query("update guanli set box1='$box1' where id='$id'");
}
if($id!="" and $box2!=""){
$query=mysql_query("update guanli set box2='$box2' where id='$id'");
}
if($id!="" and $box3!=""){
$query=mysql_query("update guanli set box3='$box3' where id='$id'");
}
if($id!="" and $box4!=""){
$query=mysql_query("update guanli set box4='$box4' where id='$id'");
}
if($id!="" and $box5!=""){
$query=mysql_query("update guanli set box5='$box5' where id='$id'");
}
if($id!="" and $box6!=""){
$query=mysql_query("update guanli set box6='$box6' where id='$id'");
}
if($id!="" and $box7!=""){
$query=mysql_query("update guanli set box7='$box7' where id='$id'");
}
if($id!="" and $box8!=""){
$query=mysql_query("update guanli set box8='$box8' where id='$id'");
}
if($id!="" and $box9!=""){
$query=mysql_query("update guanli set box9='$box9' where id='$id'");
}
?>



<?php 
//增加数据

$id=make_safe($_GET["id"]);
$action=make_safe($_GET["action"]);
$username=make_safe($_POST["username"]);
$password=make_safe($_POST["password"]);
$box1=make_safe($_POST["box1"]);
$box2=make_safe($_POST["box2"]);
$box3=make_safe($_POST["box3"]);
$box4=make_safe($_POST["box4"]);
$box5=make_safe($_POST["box5"]);
$box6=make_safe($_POST["box6"]);
$box7=make_safe($_POST["box7"]);
$box8=make_safe($_POST["box8"]);
$box9=make_safe($_POST["box9"]);

if($box1==""){$box1=0;}
if($box2==""){$box2=0;}
if($box3==""){$box3=0;}
if($box4==""){$box4=0;}
if($box5==""){$box5=0;}
if($box6==""){$box6=0;}
if($box7==""){$box7=0;}
if($box8==""){$box8=0;}
if($box9==""){$box9=0;}


include("check.php");


if($action=="add"){
if($username==""){
echo"SORRY <br>";
echo"请输入管理員帳號!<a href='javascript:history.go(-1)'>返回重输</a><br>";
}
if($password==""){
echo"SORRY <br>";
echo"请输入管理員密碼!<a href='javascript:history.go(-1)'>返回重输</a><br>";
}

if($username!="" and $password!=""){

$sql=mysql_query("select * from guanli where username = '$username'");
$result=mysql_fetch_array($sql);
if ($result!=false){
	echo "<script> alert('[".$username."] 已有的[管理員帳號]！');history.back();</script>";
}
else
{	

$sql="Insert Into guanli (username,password,box1,box2,box3,box4,box5,box6,box7,box8,box9) Values('$username','$password','$box1','$box2','$box3','$box4','$box5','$box6','$box7','$box8','$box9')";
$result=mysql_query($sql);

echo "<script> alert('管理員 增加成功！');window.location.href='admin_manage.php';</script>";
}


}
}




//删除数据
		if ($action=="del"){
	
		if($id!=""){
			$sql="Delete from guanli  where id in (".$id.")";
			$result=mysql_query($sql);
			
			echo "<script>window.location.href='admin_manage.php';</script>";
		}
	}
?>
		
		
		
<script language="javascript">
<!--

function ConfirmDel()
{
   if(confirm("確定要刪除選擇的項目嗎？一旦刪除將不能恢複！"))
     return true;
   else
     return false;	 
}


</SCRIPT>

<script language="javascript">
	function check(form1){
		if(form1.username.value==""){
			alert("请输入管理員帳號!");form1.username.focus();return false;		
		}
		if(form1.password.value==""){
			alert("请输入管理員密碼!");form1.password.focus();return false;
		}
		
		if(form1.password.value!=form1.conpassword.value){
			alert("對不起，您輸入的確認密碼不正確!");form1.conpassword.focus();return false;
		}
	}
</script>		
		
		
		
          <FORM   action="admin_manage.php?action=add" method="post" name="form1" class="tr_southidc" >	
            <td bgcolor="#B0DAFF"><table width="100%" border="0" align="center" cellspacing="1" >
                
                <tr> 
                  <td width="13%" height="22" bgcolor="#FFFFFF"> <div align="right">管理員帳號：</div></td>
                  <td width="87%" bgcolor="#FFFFFF"><input name="username" type="text" id="username" size="16" maxlength="20">
                  <input type="hidden" name="box1" value="1" /></td>
                </tr>
				
				
				
				
				
                <tr> 
                  <td height="22" bgcolor="#FFFFFF"> <div align="right">管理員密碼：</div></td>
                  <td bgcolor="#FFFFFF"><input name="password" type="password" size="16" maxlength="20"></td>
                </tr>
				
                <tr> 
                  <td height="22" bgcolor="#FFFFFF"> <div align="right">密碼確認：</div></td>
                  <td bgcolor="#FFFFFF"><input name="conpassword" type="password" size="16" maxlength="20"></td>
                </tr>
				
                <tr> 
                  <td height="22" colspan="2" bgcolor="#FFFFFF"><div align="center">
                      
                      <INPUT type=submit value='確認新增' onClick="return check(form1);"  name=Submit2>
                  </div></td>
                </tr>
            </table></td>
          </form>
        </tr>
      </table>
	  </br>
	  <table width="794" border="1" cellpadding="0" cellspacing="0" class="table_southidc">
        <tr> 
          <td  height="20" class="back_southidc"> <div align="center"><strong>管理員帳號管理</strong></div></td>
        </tr>
        <tr  class="tr_southidc">          
            <td bgcolor="#B0DAFF"><table width="790px" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0000FF">
              <tr bgcolor="#E4F2FF">
                <td width="10%" height="25"  bgcolor="#D9EDFF"><div align="center">管理員帳號</div></td>
                <td width="10%" bgcolor="#D9EDFF"><div align="center">管理員密碼</div></td>
                <td width="8%" bgcolor="#D9EDFF"><div align="center">操作</div></td>
                <td width="5%" bgcolor="#D9EDFF"><div align="center">操作</div></td>
              </tr>
              <?php 
    $sql="select * from guanli where id>0 order by id";	
	$result=mysql_query($sql);
	while ($row=mysql_fetch_object($result)){
	?>
              <tr bgcolor="#FFFFFF" onmouseover="this.style.backgroundColor='#E4F2FF'" onmouseout="this.style.backgroundColor=''">
                <td height="22"><div align="center"><?php echo $row->username;?></div></td>
                <td><div align="center"><?php echo $row->password;?></div></td>
                <td><div align="center"> <a style="color:#000000"  href='admin_password.php?id=<?php echo $row->id;?>&amp;username=<?php echo $row->username;?>'>修改密碼</a></div></td>
                <td><div align="center"> <a style="color:#000000" href="admin_manage.php?id=<?php echo $row->id;?>&amp;action=del" onclick="return ConfirmDel();">刪除</a></div></td>
              </tr>
              <?php }?>
            </table></td>         
        </tr>
      </table>
        </div>
      </div>
    </div>
  </div>
</div>
<div id="botton"><div id="copyright"><table border="0" cellpadding="0" cellspacing="0" class="copy">
  <tr>
    <td>© COPYRIGHTS 2010 INC. APARTMENT STUDIO All rights reserved.</td>
  </tr>
</table>
</div></div>
</body>
</html>
